package top.choviwu.shortUrl.util;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtils {

    public static <T> T toBean(String json ,Class<T> tClass){
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            objectMapper.setDefaultVisibility(JsonAutoDetect.Value.defaultVisibility());
            return objectMapper.readValue(json,tClass);
        }catch (Exception e){
            return null;
        }
    }
}
